package com.sskj.cndragon.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.cndragon.bean.CodeUrlBean;
import com.sskj.cndragon.http.HttpConfig;
import com.sskj.cndragon.ui.activity.SpreadActivity;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.SPUtil;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.SPConfig;
import com.sskj.lib.http.JsonCallBack;


public class SpreadActivityPresenter extends BasePresenter<SpreadActivity> {

    public void getCodeUrl() {
        httpService.getCodeUrl(SPUtil.get(SPConfig.ID, ""))
        .tag(this)
        .execute(new JsonCallBack<HttpData<CodeUrlBean>>(this) {
            @Override
            public void onSuccess(Response<HttpData<CodeUrlBean>> response) {
                HttpData<CodeUrlBean> body = response.body();
                if (body.getStatus() == HttpConfig.OK) {
                    mView.getCodeUrlOK(body.getData());
                } else {
                    ToastUtil.showShort(body.getMsg());
                }
            }
        });
    }
}
